package com.yijdn.common.utils;

import com.yijdn.common.constant.CodeStatus;

import java.io.Serializable;

/**
 * @author zww
 * @date 2018-03-25 10:53
 * <p>
 * Email 971762302@qq.com
 * <p>
 * Describe:
 */
public class ReturnModel implements Serializable {

    private int code;

    private String msg;

    private Object data;

    private Object params;

    private ReturnModel(int code, String msg){
        this(code,msg,null);
    }

    private ReturnModel(int code, String msg, Object data){
        this(code,msg,data,null);
    }

    private ReturnModel(int code, String msg, Object data, Object params){
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.params = params;
    }

    public static ReturnModel ok(){
        return ok(MessageUtils.getMsg("success"));
    }

    public static ReturnModel ok(String msg){
        return newInstant(200,msg);
    }

    public static ReturnModel error(){
        return error(MessageUtils.getMsg("error"));
    }

    public static ReturnModel error(String msg){
        return newInstant(500,msg);
    }

    public static ReturnModel newInstant(int code,String msg){
        return new ReturnModel(code,msg);
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Object getParams() {
        return params;
    }

    public void setParams(Object params) {
        this.params = params;
    }
}
